package com.gears_software.sxdc.dccx.data.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

/**
 * Created by chezhenzhen on 2017/6/26.
 */

public class FragmentAdapter extends FragmentPagerAdapter {

    List<Fragment> list;
    String[] titles;

    public FragmentAdapter(FragmentManager fm, List<Fragment> list, String[] titles) {
        super(fm);
        this.list = list;
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (titles == null) {
            return super.getPageTitle(position);
        }
        return titles[position];
    }

    @Override
    public int getCount() {
        return list.size();
    }
}
